#!/usr/bin/env python
#
# CUBudget: http://code.google.com/p/cubudget
#
# Copyright (c) 2008 Clemson University
# Released under the GNU GPL, version 2.
# Author Wallace O'Rear, Joshua Canter

import wx, cubudget

class Report(object):
   def __init__(self):
      self.core = cubudget.Core()
      self.assets = 0
      self.debts  = 0

   def makeReport(self,account):
      try:
         import reportlab
         from reportlab.pdfgen import canvas
         from reportlab.lib.units import inch

         tempAssets  = 0
         tempDebts   = 0

         for anAccount in account:
            accountObj = self.core.findAccount(anAccount)
            if(accountObj is not None):
               if(accountObj.type == '3'):
                  tempAssets += accountObj.amount
               elif(accountObj.type == '1'):
                  tempDebts -= accountObj.amount

         self.assets = tempAssets
         self.debts  = tempDebts
         c = canvas.Canvas("report.pdf")
         c.setFont("Helvetica",22)
         c.drawString(4*inch,10.2*inch,"Report")
         c.line(0,700,11*inch,700)
         #start 1inch from x-axis
         c.drawString(1*inch,9*inch,"Assets : $" + str(self.assets))
         c.drawString(1*inch,8*inch,"Debts  : $" + str(self.debts))
         c.drawString(1*inch,7*inch,"Overall: $" + str(self.assets-self.debts))
         c.showPage()
         c.save()

      except ImportError:
         print 'No Reportlab library found, get it!'
         
   def makeFakeReport(self):
      try:
         import reportlab
         from reportlab.pdfgen import canvas
         from reportlab.lib.units import inch
         self.assets = 86753.09
         self.debts  = 55555.55
         c = canvas.Canvas("report.pdf")
         c.setFont("Helvetica",22)
         c.drawString(4*inch,10.2*inch,"Report")
         c.line(0,700,11*inch,700)
         #start 1inch from x-axis
         c.drawString(1*inch,9*inch,"Assets : $" + str(self.assets))
         c.drawString(1*inch,8*inch,"Debts  : $" + str(self.debts))
         c.drawString(1*inch,7*inch,"Overall: $" + str(self.assets-self.debts))
         c.showPage()
         c.save()

      except ImportError:
         print 'No Reportlab library found, get it!'

if __name__ == '__main__':
   report = Report()
   report.makeFakeReport()
